$OpenBSD: patch-picard_musicdns_avcodec_c,v 1.1 2014/05/05 07:55:50 brad Exp $

Deal with newer FFmpeg API.

--- picard/musicdns/avcodec.c.orig	Sun Oct 23 13:15:29 2011
+++ picard/musicdns/avcodec.c	Thu May  1 04:58:17 2014
@@ -39,6 +39,10 @@
 #define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
 #endif
 
+#ifndef AVCODEC_MAX_AUDIO_FRAME_SIZE
+#define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
+#endif
+
 static PyObject *
 init(PyObject *self, PyObject *args)
 {
@@ -55,7 +59,7 @@ done(PyObject *self, PyObject *args)
 static PyObject *
 decode(PyObject *self, PyObject *args)
 {
-    AVFormatContext *format_context;
+    AVFormatContext *format_context = NULL;
     AVCodecContext *codec_context;
     AVCodec *codec;
     PyObject *filename;
@@ -69,7 +73,11 @@ decode(PyObject *self, PyObject *args)
         return NULL;
 
     Py_UNBLOCK_THREADS
+#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(53, 2, 0)
     if (av_open_input_file(&format_context, PyString_AS_STRING(filename), NULL, 0, NULL) != 0) {
+#else
+    if (avformat_open_input(&format_context, PyString_AS_STRING(filename), NULL, NULL) != 0) {
+#endif
         Py_BLOCK_THREADS
         PyErr_SetString(PyExc_Exception, "Couldn't open the file.");
         return NULL;
